package com.account.book.controller;

import com.account.book.common.response.BaseResult;
import com.account.book.common.response.ResultUtils;
import com.account.book.entity.ListMessage;
import com.account.book.request.MessageReqVo;
import com.account.book.response.DetailMessageResVo;
import com.account.book.response.ListMessageResVo;
import com.account.book.response.MainMessageResVo;
import com.account.book.response.TabsMessageResVo;
import com.account.book.service.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author liang-hw
 * @className MessageController
 * @description 信息接口
 * @date 2023/11/09 13:50:24
 */
@Api(tags = {"信息接口"})
@RestController
@RequestMapping("/api/message")
public class MessageController {

    @Autowired
    private MessageService messageService;

    /**
     * @param @param type
     * @return @return {@link BaseResult }<{@link List }<{@link ListMessage }>>
     * @author liang-hw
     * @description获取tabs列表
     * @date 2023/11/09 13:50:38
     */
    @ApiOperation(value = "获取tabs列表", notes = "获取tabs列表")
    @GetMapping("/listTabs")
    public BaseResult listTabs() {
        List<TabsMessageResVo> listTabs = messageService.listTabs();
        return ResultUtils.success(listTabs);
    }

    /**
     * @param @param tabId
     * @return @return {@link BaseResult }
     * @author liang-hw
     * @description 获取轮播列表
     * @date 2024/01/13 18:16:48
     */
    @ApiOperation(value = "获取轮播列表", notes = "获取轮播列表")
    @GetMapping("/getMainMessage")
    public BaseResult getMainMessage(@RequestParam("tabId") String tabId) {
        List<MainMessageResVo> mainMessageResVoList = messageService.getMainMessage(tabId);
        return ResultUtils.success(mainMessageResVoList);
    }

    /**
     * @param @param tabId
     * @return @return {@link BaseResult }
     * @author liang-hw
     * @description 获取列表
     * @date 2024/01/13 19:03:22
     */
    @ApiOperation(value = "获取列表", notes = "获取列表")
    @PostMapping("/getListMessage")
    public BaseResult getListMessage(@RequestBody @Valid MessageReqVo messageReqVo) {
        List<ListMessageResVo> listMessageResVos = messageService.getListMessage(messageReqVo);
        return ResultUtils.success(listMessageResVos);
    }

    /**
     * @param @param messageReqVo
     * @return @return {@link BaseResult }
     * @author liang-hw
     * @description 更新列表
     * @date 2024/01/13 19:07:48
     */
    @ApiOperation(value = "更新列表", notes = "更新列表")
    @PostMapping("/addListMessage")
    public BaseResult addListMessage(@RequestBody @Valid MessageReqVo messageReqVo) {
        messageService.addListMessage(messageReqVo);
        return ResultUtils.success();
    }

    @ApiOperation(value = "获取列表详情", notes = "获取列表详情")
    @GetMapping("/getDetailMessage")
    public BaseResult getDetailMessage(@RequestParam("listId") String listId) {
        DetailMessageResVo detailMessageResVos = messageService.getDetailMessage(listId);
        return ResultUtils.success(detailMessageResVos);
    }
}
